<?php
  //Updated delcourses.php
  
    if(!isset($_GET['cid'])) { ?>

<html>
<head>
<h2>Delete Course Record</h2>
<style>
  html {
        overflow: scroll; 
      }
.scrollable{
   overflow: auto;
   width: 70px; /* adjust this width depending to amount of text to display */
   height: 80px; /* adjust height depending on number of options to display */
   border: 1px silver solid;
 }
body{background-image:url('Images/sjsu logo.jpg');
      
background-repeat: no-repeat;
  background position: top center;
  background-size: 100%;
  background-size: 1400px 1200px;
  position:relative;}
  
h3.pos_fixed{
color:#6D63A9;
position:relative;
//top:25px;
//left:30px;

}
#b{
position:relative;
top:140px;
left:320px;
}

form {
position:relative;
top:140px;
left:320px;
}

h2 {
position:relative;
top:140px;
left:320px;
}


a:link    {
  /* Applies to all unvisited links */
  text-decoration:  none;
  font-weight:      bold;
  color:          "#blue";
  font-size:120%;
  text-align: center;
  } 

</style>
</head>

<body>
<form action="delcourses.php" method="GET">
Course Id: <input type='text' name = 'cid' /> <br/>

<input type='submit' name = 'Delete' value='Delete'/>

</form>
</body>

<br />
<div id="b"><a href="MainMenu.php">Home</a>
</html>

<?php } else {  ?>

<html>
<head>

<style>
  html {
        overflow: scroll; 
      }
.scrollable{
   overflow: auto;
   width: 70px; /* adjust this width depending to amount of text to display */
   height: 80px; /* adjust height depending on number of options to display */
   border: 1px silver solid;
 }
body{background-image:url('Images/sjsu logo.jpg');
      
background-repeat: no-repeat;
  background position: top center;
  background-size: 100%;
  background-size: 1400px 1200px;
  position:relative;}
  
h3.pos_fixed{
color:#6D63A9;
position:relative;
//top:25px;
//left:30px;

}
#b{
position:relative;
top:140px;
left:320px;
}

form {
position:relative;
top:140px;
left:320px;
}

h2 {
position:relative;
top:140px;
left:320px;
}


a:link    {
  /* Applies to all unvisited links */
  text-decoration:  none;
  font-weight:      bold;
  color:          "#blue";
  font-size:120%;
  text-align: center;
  } 

</style>

<?php
    require "config.php";
	error_reporting(0);
	$cid = $_GET['cid'];
	//echo "Course id is : ".$cid;
	//$con = mysql_connect("localhost",$db_user ,$db_pass);
	$con = mysql_connect($db_host,$db_user,$db_pass);


	// if an error was encountered, the script exits with an error message
	if (!$con){
		die('Could not connect: ' . mysql_error());
    }
	//after successfully connecting with the database server, select the database with which you want to communicate
	mysql_select_db($db_name,$con);
		
	$sql_del = "DELETE FROM course WHERE courseId = '$cid'";
	$result1 = mysql_query($sql_del,$con);
	
	//echo "The result of this delete operation is : ". $result1;
	mysql_close($con);
	?>
	
	<h2> Course Record Deleted Successfully!</h2>

</head>
<body>
</body>
<div id="b"><a href="MainMenu.php">Home</a>
</html>

<?php
}

?>